//
//  EFengShareButton.m
//  WZEfengAndEtong
//
//  Created by wanzhao on 16/2/29.
//  Copyright © 2016年 wanzhao. All rights reserved.
//

#import "EFengShareButton.h"
#import "UIImage+ImageWithColor.h"

@interface EFengShareButton ()

AssignProperty NSInteger corners;
StrongProperty UIColor *selectedColor;
StrongProperty UIColor *normalColor;

@end

@implementation EFengShareButton

+ (instancetype)buttonwithCorners:(NSInteger)corners selectedColor:(UIColor *)selectedColor normalColor:(UIColor *)normalColor
{
    
    EFengShareButton *share = [EFengShareButton buttonWithType:UIButtonTypeCustom];
    share.corners = corners;
    share.selectedColor = selectedColor;
    share.normalColor = normalColor;
    return share;
}

- (void)setSelected:(BOOL)selected
{
    [super setSelected:selected];
    if (selected) {
        self.backgroundColor = self.selectedColor;
    } else {
        self.backgroundColor = self.normalColor;
    }
}

- (void)drawRect:(CGRect)rect
{
    UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:self.bounds
                                                   byRoundingCorners:self.corners
                                                         cornerRadii:CGSizeMake(10.0, 0.0f)];
    [RGBCOLORWITH16COLOR(0xd4ded4) setStroke];
    [maskPath stroke];
    CAShapeLayer *maskLayer = [CAShapeLayer layer];
    maskLayer.frame         = self.bounds;
    maskLayer.path          = maskPath.CGPath;
    
    //    maskLayer.lineWidth = 1.0f;
    
    self.layer.mask         = maskLayer;

}
- (void)layoutSubviews
{
    [super layoutSubviews];
    
}
@end
